
<?php
ob_start();
include("../connection.php");
include("heder1.php");
?>


<?php
ob_start();

if($_GET['action']=="send")
{
 $id=$_GET['id'];
 
 $q=mysql_query("SELECT * FROM users WHERE id='".$id."'")or die(			    mysql_error());
 
 $row = mysql_fetch_array($q);
 
  	$fname=$row["fname"];
	$lname=$row["lname"];
	$email=$row["email"];
	$phoneno=$row["phoneno"];

?>
<form name="form1" method="post" action="usercontact.php?action=send&id=<?php echo $_GET['id']; ?>">
<table width="415" border="1" cellspacing="0" cellpadding="0">
  <tr>
    <td colspan="2"><div align="center"><h2>SEND E-MAIL</h2> </div></td>
  </tr>
  <tr>
    <td width="135"><h4>Firstname </h4></td>
    <td width="197">
      
   
     <input type="text" name="fname" value="<?php echo $fname; ?>"></td>
  </tr>
  <tr>
    <td><h4>Lastname</h4></td>
    <td><label>
      <input type="text" name="lname" value="<?php  echo $lname; ?>" >
    </label></td>
  </tr>
 
  <tr>
    <td><h4>Phone Nomber</h4></td>
    <td><input type="text" name="phoneno" value="<?php  echo $phoneno; ?>"></td>
  </tr> 
   <tr>
    <td><h4>E-mail address</h4></td>
    <td><input type="text" name="emailaddress" value="<?php  echo $email?>"></td>
  </tr>
 
 <tr>
    <td><h4>Subject</h4></td>
    <td><label>
      <input type="text" name="subject" value="" >
    </label></td>
  </tr>
  <tr>
    <td><h4>Message</h4></td>
    <td><textarea name="message" cols="30" rows="5"></textarea></td>
  </tr> 
  <tr>
    <td colspan="2"><label>
      <div align="center">
        <input type="submit" name="Submit2" value="send mail" />
      </div>
    </label></td>
  </tr>
</table>
</form>



<?php
}

if($_GET["action"]=="send")
{
	 $fname=$_POST["fname"];
	 $lname=$_POST["lname"];
	 $phoneno=$_POST["phoneno"];
	 $emailaddress=$_POST["email"];
	 $subject=$_POST["subject"];
	 $message=$_POST["message"];
// mail( $emailaddress,$subject,$message );			  
				 // echo "send your mail";
} 



?>
<?php
$result=mysql_query("SELECT * FROM users");
	$total = mysql_num_rows($result);
	$i=0;
	 echo'<table width="600" border="1" cellspacing="0" cellpadding="0">
  <tr>
    <td>Firstname</td>
    <td>Lastname</td>
    <td>E-mail</td>
    <td>Phone number</td>
    <td>Send E-mail</td>
  </tr>';


	while($i< $total)
	{
	$row=mysql_fetch_array($result);
	$id=$row["Id"];
	$fname=$row["fname"];
	$lname=$row["lname"];
	$email=$row["email"];
	$phoneno=$row["phoneno"];
	
	//echo $eventname."<br>";
	//echo $vanue."<br>";
	//echo $date."<br>";
	echo"
	<tr>
	<td>".$fname."</td>
    <td>".$lname."</td>
    <td>".$email."</td>
    <td>".$phoneno."</td>
    <td><a href='?action=send&id=".$row["Id"]."'><img src='send.png' border='0'/><a/>
	</td>
	
	</tr>";
	
	$i++;
	}
	echo "</table>";
	include("../footer.php");
?>